home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / System / SysBeep INIT / SysBeep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-13  |  690 b   |  55 lines  |  [TEXT/KAHL]

  1. #include <sound.h>
  2.  
  3.  
  4. pascal void main(int duration)
  5. {
  6. Handle        soundHand;
  7. int            numSnds,theSnd;
  8. short        volume;
  9.  
  10.     asm
  11.     {
  12.             movem.l        d0-d7/a0-a6,-(sp)
  13.             
  14.             bra.s        @skip
  15.             
  16.             dc.b        "moof"
  17. oldTrap:    dc.l        0
  18.             dc.l        0
  19.  
  20. skip:        nop
  21.     }
  22.     
  23.     GetSoundVol(&volume);
  24.     
  25.     if (volume > 0)
  26.     {
  27.         numSnds = CountResources((long) 'snd ');
  28.         theSnd = ((Random() & 0x7FFF) % numSnds) + 1;
  29.         
  30.         soundHand = GetIndResource((long) 'snd ',theSnd);
  31.     }
  32.     
  33.     if (volume <= 0 || soundHand == 0L)
  34.     {
  35.         asm 
  36.         {
  37.                 movem.l        (sp)+,d0-d7/a0-a6
  38.                 unlk        a6
  39.                 move.l        @oldTrap,-(sp)
  40.                 rts
  41.         }
  42.     }
  43.     
  44.     
  45.     SndPlay(0L,soundHand,FALSE);
  46.     
  47.     HUnlock(soundHand);
  48.     HPurge(soundHand);
  49.     
  50.     asm 
  51.     {
  52.             movem.l        (sp)+,d0-d7/a0-a6
  53.     }
  54. }
  55.